# 定义 mcp 工具
def mcp_tool_func(xiaozhi):
    async def mcp_take_photo(data) -> tuple[dict, bool]:
        # 实现拍照功能
        with open("./xiaozhi_sdk/file/image/leijun.jpg", "rb") as f:
            res = await xiaozhi.async_analyze_image(f.read(), data["question"])
            return res, False

    def mcp_get_device_status(data) -> tuple[dict, bool]:
        # 实现获取设备状态功能
        return {
            "audio_speaker": {"volume": 80},
            "screen": {"brightness": 75, "theme": "light"},
            "network": {"type": "wifi", "ssid": "wifi名称", "signal": "strong"},
        }, False

    def mcp_set_volume(data) -> tuple[dict, bool]:
        # 实现设置音量功能
        return {}, False

    from xiaozhi_sdk.utils.mcp_tool import get_device_status, set_volume, take_photo

    take_photo["tool_func"] = mcp_take_photo
    take_photo["is_async"] = True
    get_device_status["tool_func"] = mcp_get_device_status
    set_volume["tool_func"] = mcp_set_volume

    # 返回工具函数映射
    return [take_photo, get_device_status, set_volume]
